<?php 
ob_start();
session_start();
require('../gest_login.php');
require('../languages/it.php');
require('../structure.php');
//reserved_page();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
	var page = "";
</script>
<script type="text/javascript" src="validate.js"></script>
<?php
get_header();
get_css();
get_js();
?>
</head>
<!-- recupero le mail dal db in php -->
<?php
include("../database.php"); 	
mysql_select_db($database_database, $database);
$query = "SELECT mail FROM users";
$result = mysql_query($query, $database) or die(mysql_error());
$result_rows = mysql_num_rows($result);

//creo array php con indirizzi mail
$i=0;
while($row=mysql_fetch_array($result)){
$mails[$i] = $row['mail'];
$i++;
}

?>
<!-- salvo in un array Js le mail del DB -->
<script language="javascript"> 
var mails = new Array(); 
<? for($i=0; $i<$result_rows; $i++) { ?> 
mails[<?= $i ?>] = "<?= $mails[$i] ?>"; 
<? } ?> 

</script>
<body class="grunge">
<div id="wrapper">
	<div id="header_container">
		<div id="header">
			<h1 id="logo"> <a href="index.html">Xero HTML &amp; CSS Template</a> </h1>
			<!-- end logo -->
			
			<?php get_nav(); ?>
			
			<div class="clear"></div>
			<!-- clears floted logo & nav -->
			
			<div id="page_title">
				<ul class="breadcrumb_nav">
					<li><a href="../">Home</a></li>
					<li><a href="#">Registrati</a></li>
				</ul>
				<h1>Recupero Password</h1>
			</div>
			<!-- end page title -->
			
		</div>
		<!-- end header (940px width) --> 
	</div>
	<!-- end header container (100% width) -->
	<div id="body_content">
		<div id="content" class="">
			<div class="full">
				<h2>Recupero password da indirizzo mail<em class="heading_description">Inserisci la mail con cui ti sei registrato su Ragusainfoto e ti invieremo una nuova password.</em></h2>
				<form id="reset_pass" method="post" name="req">
				<ol>
				<li>
					<label for="mail" class="auto_clear">Mail</label>
					<input type="text" name="mail" id="mail" class="text_field small" style="display:inline;" onblur="check_mail()">
					<span id="no_mail" class="error_notice" style="margin-left:10px; padding:6px; padding-left:45px; display:none;" >Inserire la mail</span>
					<span id="invalid_mail" class="error_notice" style="margin-left:10px; padding:6px; padding-left:45px; display:none;" >Mail non valida</span>
					<span id="no_exist_mail" class="error_notice" style="margin-left:10px; padding:6px; padding-left:45px; display:none;" >Mail non presente</span>
				</li>
				</ol>
				</form>
				<button onclick="validate_new_pass()">Registrati</button>	
				<?php
				
				if(isset($_POST['mail']))
				{
					?>
						<br/>
						<span class="success_notice" id="req_ok">Registrazione OK</span>
					<?php
					reset_password($_POST['mail']);
				}
				
				?>
			</div>
		</div>
	</div>
	<!-- end body content -->
	
	<?php get_footer(); ?>
	
</div>
<!-- end wrapper -->
</body>
</html>
